package com.nhim.cms.domain;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.nhim.security.domain.Group;

/**
 * ContentType entity. @author Huy Lieu Ta
 */
@Entity
@Table(name = "nhim_content_type", catalog = "nhim_cms")
public class ContentType implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// Fields

	private Integer id;
	private String description;
	private String filter;
	private String imageUrl;
	private Boolean isFile;
	private Integer maxSize;
	private String name;
	private Integer position;
	private Set<Group> groups = new HashSet<Group>(0);
	private Set<ContentTypeElementDefinition> contentTypeElementDefinitions = new HashSet<ContentTypeElementDefinition>(
			0);

	// Constructors

	/** default constructor */
	public ContentType() {
	}

	/** minimal constructor */
	public ContentType(String name) {
		this.name = name;
	}

	/** full constructor */
	public ContentType(String description, String filter, String imageUrl,
			Boolean isFile, Integer maxSize, String name, Integer position,
			Set<Group> groups,
			Set<ContentTypeElementDefinition> contentTypeElementDefinitions) {
		this.description = description;
		this.filter = filter;
		this.imageUrl = imageUrl;
		this.isFile = isFile;
		this.maxSize = maxSize;
		this.name = name;
		this.position = position;
		this.groups = groups;
		this.contentTypeElementDefinitions = contentTypeElementDefinitions;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "description", length = 200)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "filter")
	public String getFilter() {
		return this.filter;
	}

	public void setFilter(String filter) {
		this.filter = filter;
	}

	@Column(name = "image_url")
	public String getImageUrl() {
		return this.imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	@Column(name = "is_file")
	public Boolean getIsFile() {
		return this.isFile;
	}

	public void setIsFile(Boolean isFile) {
		this.isFile = isFile;
	}

	@Column(name = "max_size")
	public Integer getMaxSize() {
		return this.maxSize;
	}

	public void setMaxSize(Integer maxSize) {
		this.maxSize = maxSize;
	}

	@Column(name = "name", nullable = false, length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "position")
	public Integer getPosition() {
		return this.position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "nhim_content_type_group", catalog = "nhim_cms", joinColumns = { @JoinColumn(name = "content_type_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "group_id", nullable = false, updatable = false) })
	public Set<Group> getGroups() {
		return this.groups;
	}

	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "contentType")
	public Set<ContentTypeElementDefinition> getContentTypeElementDefinitions() {
		return this.contentTypeElementDefinitions;
	}

	public void setContentTypeElementDefinitions(
			Set<ContentTypeElementDefinition> contentTypeElementDefinitions) {
		this.contentTypeElementDefinitions = contentTypeElementDefinitions;
	}

}